package app.texas.com.devilfishhouse.View.regitst;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.universal_library.utils.StringUtil;
import com.universal_library.weight.AppToast;

import app.texas.com.devilfishhouse.Base.BasePresenter;
import app.texas.com.devilfishhouse.Base.BaseView;
import app.texas.com.devilfishhouse.R;
import butterknife.BindView;
import butterknife.OnClick;

public class RegistView extends BaseView implements View.OnClickListener {
    RegistPresenter presenter;

    @BindView(R.id.et_phone)
    EditText et_phone;

    @BindView(R.id.et_code)
    EditText et_code;

    @BindView(R.id.bt_getcode)
    Button bt_getcode;

    @BindView(R.id.et_pwd)
    EditText et_pwd;

    @BindView(R.id.bt_regist)
    Button bt_regist;

    @BindView(R.id.et_zfb)
    EditText et_zfb;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_regist;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        super.initView();
        initTitle();
    }

    @Override
    protected BasePresenter getPresenter() {
        presenter = new RegistPresenter(this);
        return presenter;
    }

    @OnClick({R.id.bt_getcode, R.id.bt_regist})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_getcode:
                if (StringUtil.isNull(et_phone)) {
                    AppToast.showToast(this, "请输入手机号", "");
                    return;
                }
                presenter.getCode(et_phone.getText().toString());
                break;
            case R.id.bt_regist:
                if (StringUtil.isNull(et_phone)) {
                    AppToast.showToast(this, "请输入手机号", "");
                    return;
                }
                if (StringUtil.isNull(et_code)) {
                    AppToast.showToast(this, "请输入验证码", "");
                    return;
                }
                if (StringUtil.isNull(et_pwd)) {
                    AppToast.showToast(this, "请输入密码", "");
                    return;
                }
                if (StringUtil.isNull(et_zfb)) {
                    AppToast.showToast(this, "请输入支付宝账号", "");
                    return;
                }
                presenter.regist(et_phone.getText().toString(), et_code.getText().toString(),
                        et_pwd.getText().toString(), et_zfb.getText().toString());
                break;
        }
    }

    @Override
    protected int getTitleRes() {
        return R.string.regist;
    }

    /**
     * 设置验证码
     *
     * @param data
     */
    public void setCode(Object data) {

    }

    /**
     * 注册结果
     *
     * @param data
     */
    public void setResult(Object data) {

    }

}
